package com.code.leetcode.offer;

import com.code.leetcode.utils.TreeNode;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/31 19:11
 */
public class The26 {
    public boolean isSubStructure(TreeNode A, TreeNode B) {
        return (A != null && B != null) && (issuTree(A, B) || isSubStructure(A.right, B) || isSubStructure(A.left, B));
    }
    public boolean issuTree(TreeNode A, TreeNode B) {
        if (B == null) return true;
        if (A.val != B.val) return false;
        return issuTree(A.left, B.left) && issuTree(A.right, B.right);
    }
}
